package Servlet;

import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;
@WebServlet("/demo01")
public class ServletDemo implements Servlet {
    public void init(ServletConfig servletConfig) throws ServletException {
     // System.out.println("init....");
    }
    public ServletConfig getServletConfig() {
        return null;
    }

    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        System.out.println("hello");
        //获取URL参数名为username的值
        String username = servletRequest.getParameter("username");
        System.out.println(username);
        //获取URL所有参数的值
        Map<String, String[]> parameteramMap = servletRequest.getParameterMap();
        parameteramMap.forEach((key,value)->{
            System.out.print(key + " : ");
            System.out.println(Arrays.toString(value));
        });
  }
    public String getServletInfo() {
        return null;
    }
    public void destroy() {

    }
}
